#include "config.h"
#include "aux_errno.h"
#include "aux_types.h"
#include "aux_socket.h"
#include "aux_debugmsg.h"
#include "aux_queuemanager.h"
#include "aux_idmanager.h"
#include "aux_datacheck.h"

/* only once */
EErrNo xIPC_Init(void)
{
#define __FUNCTION_NAME__ "xIPC_Init"
    AUX_DEBUG_STR("------xIPC init------------\n");

    if (ERRNO_SUCCESS != xIPCComponentDataCheckInit())
    {
        AUX_ERR_STR("xIPCComponentDataCheckInit fail\n");
        return -FERR(1);
    }

    if (ERRNO_SUCCESS != xIPCComponentIdManagerInit())
    {
        AUX_ERR_STR("xIPCComponentIdManagerInit fail\n");
        return -FERR(4);
    }

    if (ERRNO_SUCCESS != xIPCComponentSocketInit())
    {
        AUX_ERR_STR("xIPCComponentSocketInit fail\n");
        return -FERR(2);
    }

    if (ERRNO_SUCCESS != xIPCComponentQueueManagerInit())
    {
        AUX_ERR_STR("xIPCComponentQueueManagerInit fail\n");
        return -FERR(3);
    }

    if (ERRNO_SUCCESS != xIPCCoreIOInterfaceInit())
    {
        AUX_ERR_STR("xIPCCoreIOInterfaceInit fail\n");
        return -FERR(5);
    }



    return ERRNO_SUCCESS;
#undef __FUNCTION_NAME__
}

/* only once */
EErrNo xIPC_Deinit(void)
{
#define __FUNCTION_NAME__ "xIPC_Deinit"



    if (ERRNO_SUCCESS != xIPCCoreIOInterfaceDeinit())
    {
        AUX_ERR_STR("xIPCCoreIOInterfaceDeinit fail\n");
        return -FERR(1);
    }

    //
    if (ERRNO_SUCCESS != xIPCComponentIdManagerDeinit())
    {
        AUX_ERR_STR("xIPCComponentIdManagerDeinit fail\n");
        return -FERR(2);
    }

    if (ERRNO_SUCCESS != xIPCComponentQueueManagerDeinit())
    {
        AUX_ERR_STR("xIPCComponentQueueManagerDeinit fail\n");
        return -FERR(3);
    }

    if (ERRNO_SUCCESS != xIPCComponentSocketDeinit())
    {
        AUX_ERR_STR("xIPCComponentSocketDeinit fail\n");
        return -FERR(4);
    }

    if (ERRNO_SUCCESS != xIPCComponentDataCheckDeinit())
    {
        AUX_ERR_STR("xIPCComponentDataCheckDeinit fail\n");
        return -FERR(5);
    }

    return ERRNO_SUCCESS;
 #undef __FUNCTION_NAME__
}

char *xIPC_GetVersion()
{
    return "1";
}
